package com.fr.report.write;

import com.fr.base.FRContext;
import com.fr.base.StringUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.Report;
import com.fr.report.TableDataSource;
import com.fr.report.script.Calculator;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public abstract class AbstractSubmiter
  implements Submiter
{
  private String condition;

  public String getCondition()
  {
    return this.condition;
  }

  public void setCondition(String paramString)
  {
    this.condition = paramString;
  }

  public void execute(Report paramReport, TableDataSource paramTableDataSource, Map paramMap)
    throws Exception
  {
    if (!(StringUtils.isBlank(this.condition)))
    {
      Calculator localCalculator = Calculator.createStaticCalculator();
      localCalculator.setCurrentReport(paramReport);
      localCalculator.setCurrentTableDataSource(paramTableDataSource);
      Object localObject = localCalculator.eval(this.condition);
      localCalculator.release();
      if (!(Boolean.TRUE.equals(localObject)))
      {
        FRContext.getLogger().log(Level.INFO, "The condition " + this.condition + " is non-compliance");
        throw new MismatchException();
      }
    }
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("Condition".equals(paramXMLableReader.getTagName())))
      setCondition(paramXMLableReader.getElementValue());
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (StringUtils.isNotBlank(this.condition))
      paramXMLPrintWriter.startTAG("Condition").textNode(this.condition).end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}